﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Student
{
    public partial class login : Form
    {
        public login()
        {
            InitializeComponent();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void login_button_Click(object sender, EventArgs e)
        {           
            Model.Student student = new Model.Student(); 
            // 组件的命名要分清楚
            student.stu_no = this.stu_no_box.Text;
            student.pwd = this.stu_pwd_box.Text;//model模块完成

            BLL.B_Student b_Student = new BLL.B_Student();
            bool res = b_Student.Login(student);
            if (res)
            {
                this.DialogResult = DialogResult.OK;
                MessageBox.Show("账号密码正确，登录成功");
            }
            else
            {
                MessageBox.Show("密码或用户名有误", "消息提示框", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);//
                stu_no_box.Text = "";//置空
                stu_pwd_box.Text = "";//置空
                stu_no_box.Focus();//光标回到用户输入栏
            }
        }

    

        private void show_cursor(object sender, EventArgs e)//
        {
            stu_no_box.Focus();//
        } 
        
        private void textBox1_MouseEnter(object sender, EventArgs e)
        {
            stu_no_box.Focus();//
        }

        private void textBox2_MouseEnter(object sender, EventArgs e)
        {
            stu_pwd_box.Focus();//
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
